package com.darcytech.debezium.trans;

import java.util.Objects;
import java.util.Set;

public class RegisterInfo {

    public static final String SCHEMA_SUFFIX = "_cdc_ddl";

    /**
     * group为业务组，如:质检
     */
    String group;

    /**
     * 所有节点信息
     */
    Set<NodeInfo> nodeInfos;

    /**
     * 节点要监听的所有的表
     */
    Set<String> tables;

    public RegisterInfo(String group, Set<NodeInfo> nodeInfos, Set<String> tables) {
        this.group = group;
        this.nodeInfos = nodeInfos;
        this.tables = tables;
    }

    public String getGroup() {
        return group;
    }

    public Set<NodeInfo> getNodeInfos() {
        return nodeInfos;
    }

    public Set<String> getTables() {
        return tables;
    }

    public static class NodeInfo {

        String hostName;

        /**
         * dataBase 唯一
         */
        String dataBase;

        Integer port;

        String user;

        String password;

        public NodeInfo(String hostName, String dataBase, Integer port) {
            this.hostName = hostName;
            this.dataBase = dataBase;
            this.port = port;
        }

        public String getHostName() {
            return hostName;
        }

        public String getDataBase() {
            return dataBase;
        }

        public Integer getPort() {
            return port;
        }

        public String getUser() {
            return user;
        }

        public void setUser(String user) {
            this.user = user;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            NodeInfo nodeInfo = (NodeInfo) o;
            return Objects.equals(dataBase, nodeInfo.dataBase);
        }

        @Override
        public int hashCode() {
            return Objects.hash(dataBase);
        }
    }
}


